package academic.service;

import academic.dao.WcqAcademicDao;
import academic.domain.WcqAcademic;
import common.dao.StudentDao;
import common.domain.Student;
import utils.DAOFactory;

import java.util.List;

public class stutest {
    private static WcqAcademicDao wcqAcademicDao = DAOFactory.getInstance().getWcqAcademicDao();
    private static StudentDao studentDao = DAOFactory.getInstance().getStudentDao();
    public static void main(String[] args) {
        System.out.println("xxx");
//        submitStudentAcademic(1L);
        selectStudentAcademic(1L);
    }
    //查看学生提交的活动申请表
    public static void selectStudentAcademic(Long user_id)
    {
        Student student =studentDao.selectById(user_id);
        if(student.getStudentId() == null){
            System.out.println("该学号学生不存在!");
            return;
        }
        List<WcqAcademic> wcqAcademicList=wcqAcademicDao.selectByUserId(user_id);
        System.out.println("该学生共提交了"+wcqAcademicList.size()+"个活动申请表，分别是：");
        System.out.println("活动申请表id\t用户id\t活动名称\t导师审核状态\t学科负责人审核状态\t申请表状态\t备注\t");
        for(int i=0;i<wcqAcademicList.size();i++)
        {
            System.out.println(wcqAcademicList.get(i).getActivity_id()+"\t"+wcqAcademicList.get(i).getUser_id()+"\t"+wcqAcademicList.get(i).getActivity_name()+"\t"+wcqAcademicList.get(i).getActivity_status1()+"\t"+wcqAcademicList.get(i).getActivity_status2()+"\t"+wcqAcademicList.get(i).getActivity_status()+"\t"+wcqAcademicList.get(i).getActivity_comment()+"\t");
        }
    }
    public static void submitStudentAcademic(Long user_id,WcqAcademic wcqAcademic)
    {
//        WcqAcademic wcqAcademic=new WcqAcademic();
        Student student =studentDao.selectById(user_id);
        List<WcqAcademic> wcqAcademicList=wcqAcademicDao.selectByUserId(user_id);
        if(wcqAcademicList.size()>0)
        {
            wcqAcademic.setActivity_id(wcqAcademicList.get(wcqAcademicList.size()-1).getActivity_id()+1);
        }else {
            wcqAcademic.setActivity_id(1L);
        }
        wcqAcademic.setUser_id(user_id);
//        wcqAcademic.setActivity_name("活动1");
//        wcqAcademic.setActivity_photo("xxxx");
//        wcqAcademic.setActivity_addr("北京林业大学");
//        wcqAcademic.setActivity_time("2022-12-26");
//        wcqAcademic.setActivity_info("论文1");
        wcqAcademic.setActivity_status1(0);
        wcqAcademic.setActivity_status2(0);
        wcqAcademic.setActivity_status(0);
//        wcqAcademic.setActivity_comment("可以很不错");
        wcqAcademicDao.insert(wcqAcademic);
    }

}
